﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MCMesServer.PublicLogInfo
{
    public class PublicLogInfoFunc
    {
        private static readonly log4net.ILog log_info = log4net.LogManager.GetLogger("loggerinfo");

        public static void ShowWarning(string msg)
        {
            UIMessageBox.ShowWarning(msg);
        }

        public static void ShowError(string step, string msg)
        {
            log_info.Error($"[{step}]发生错误，错误信息：\r\n{msg}");
            UIMessageBox.ShowError(msg);
        }

        public static bool ShowAsk(string msg)
        {
            return UIMessageBox.ShowAsk(msg);
        }

        public static void ShowSuccess(string msg)
        {
            UIMessageBox.ShowSuccess(msg);
        }

        public static void RecordManualErrorMessage(string step, string msg)
        {
            log_info.Error($"[{step}]发生错误，错误信息：\r\n{msg}");
        }

        public static void RecordManualInfoMessage(string step, string msg)
        {
            log_info.Error($"[{step}]记录信息：\r\n{msg}");
        }

        public static void RecordSendMessage(string step, string order, string operation, string msg)
        {
            log_info.Info($"[{step}]环节发送信息至[{order}]：[{operation}]:\r\n{msg}");
        }

        /// <summary>
        /// 记录接收数据
        /// </summary>
        /// <param name="step">环节</param>
        /// <param name="orign">数据来源</param>
        /// <param name="operation">操作</param>
        /// <param name="msg">数据</param>
        public static void RecordReceiveMessage(string step, string orign, string operation, string msg)
        {
            log_info.Info($"[{step}]环节接收来自[{orign}]的信息：[{operation}]:\r\n{msg}");
        }
    }
}
